/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.vportal.portlet.vcms.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import com.vportal.portlet.vcms.model.VcmsArticleStatus;
import com.vportal.portlet.vcms.model.VcmsArticleStatusModel;
import com.vportal.portlet.vcms.model.VcmsArticleStatusSoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * The base model implementation for the VcmsArticleStatus service. Represents a row in the &quot;VcmsArticleStatus&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.vportal.portlet.vcms.model.VcmsArticleStatusModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link VcmsArticleStatusImpl}.
 * </p>
 *
 * @author hai
 * @see VcmsArticleStatusImpl
 * @see com.vportal.portlet.vcms.model.VcmsArticleStatus
 * @see com.vportal.portlet.vcms.model.VcmsArticleStatusModel
 * @generated
 */
@JSON(strict = true)
public class VcmsArticleStatusModelImpl extends BaseModelImpl<VcmsArticleStatus>
	implements VcmsArticleStatusModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a vcms article status model instance should use the {@link com.vportal.portlet.vcms.model.VcmsArticleStatus} interface instead.
	 */
	public static final String TABLE_NAME = "VcmsArticleStatus";
	public static final Object[][] TABLE_COLUMNS = {
			{ "id_", Types.BIGINT },
			{ "statusId", Types.BIGINT },
			{ "articleId", Types.VARCHAR },
			{ "categoryId", Types.VARCHAR },
			{ "createdDate", Types.TIMESTAMP },
			{ "createdByUser", Types.VARCHAR },
			{ "active_", Types.BOOLEAN },
			{ "articleVersionId", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table VcmsArticleStatus (id_ LONG not null primary key,statusId LONG,articleId VARCHAR(75) null,categoryId VARCHAR(75) null,createdDate DATE null,createdByUser VARCHAR(200) null,active_ BOOLEAN,articleVersionId LONG)";
	public static final String TABLE_SQL_DROP = "drop table VcmsArticleStatus";
	public static final String ORDER_BY_JPQL = " ORDER BY vcmsArticleStatus.createdDate ASC";
	public static final String ORDER_BY_SQL = " ORDER BY VcmsArticleStatus.createdDate ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.vportal.portlet.vcms.model.VcmsArticleStatus"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.vportal.portlet.vcms.model.VcmsArticleStatus"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.vportal.portlet.vcms.model.VcmsArticleStatus"),
			true);
	public static long ACTIVE_COLUMN_BITMASK = 1L;
	public static long ARTICLEID_COLUMN_BITMASK = 2L;
	public static long CREATEDBYUSER_COLUMN_BITMASK = 4L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static VcmsArticleStatus toModel(VcmsArticleStatusSoap soapModel) {
		VcmsArticleStatus model = new VcmsArticleStatusImpl();

		model.setId(soapModel.getId());
		model.setStatusId(soapModel.getStatusId());
		model.setArticleId(soapModel.getArticleId());
		model.setCategoryId(soapModel.getCategoryId());
		model.setCreatedDate(soapModel.getCreatedDate());
		model.setCreatedByUser(soapModel.getCreatedByUser());
		model.setActive(soapModel.getActive());
		model.setArticleVersionId(soapModel.getArticleVersionId());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<VcmsArticleStatus> toModels(
		VcmsArticleStatusSoap[] soapModels) {
		List<VcmsArticleStatus> models = new ArrayList<VcmsArticleStatus>(soapModels.length);

		for (VcmsArticleStatusSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.vportal.portlet.vcms.model.VcmsArticleStatus"));

	public VcmsArticleStatusModelImpl() {
	}

	public long getPrimaryKey() {
		return _id;
	}

	public void setPrimaryKey(long primaryKey) {
		setId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_id);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return VcmsArticleStatus.class;
	}

	public String getModelClassName() {
		return VcmsArticleStatus.class.getName();
	}

	@JSON
	public long getId() {
		return _id;
	}

	public void setId(long id) {
		_id = id;
	}

	@JSON
	public long getStatusId() {
		return _statusId;
	}

	public void setStatusId(long statusId) {
		_statusId = statusId;
	}

	@JSON
	public String getArticleId() {
		if (_articleId == null) {
			return StringPool.BLANK;
		}
		else {
			return _articleId;
		}
	}

	public void setArticleId(String articleId) {
		_columnBitmask |= ARTICLEID_COLUMN_BITMASK;

		if (_originalArticleId == null) {
			_originalArticleId = _articleId;
		}

		_articleId = articleId;
	}

	public String getOriginalArticleId() {
		return GetterUtil.getString(_originalArticleId);
	}

	@JSON
	public String getCategoryId() {
		if (_categoryId == null) {
			return StringPool.BLANK;
		}
		else {
			return _categoryId;
		}
	}

	public void setCategoryId(String categoryId) {
		_categoryId = categoryId;
	}

	@JSON
	public Date getCreatedDate() {
		return _createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		_columnBitmask = -1L;

		_createdDate = createdDate;
	}

	@JSON
	public String getCreatedByUser() {
		if (_createdByUser == null) {
			return StringPool.BLANK;
		}
		else {
			return _createdByUser;
		}
	}

	public void setCreatedByUser(String createdByUser) {
		_columnBitmask |= CREATEDBYUSER_COLUMN_BITMASK;

		if (_originalCreatedByUser == null) {
			_originalCreatedByUser = _createdByUser;
		}

		_createdByUser = createdByUser;
	}

	public String getOriginalCreatedByUser() {
		return GetterUtil.getString(_originalCreatedByUser);
	}

	@JSON
	public boolean getActive() {
		return _active;
	}

	public boolean isActive() {
		return _active;
	}

	public void setActive(boolean active) {
		_columnBitmask |= ACTIVE_COLUMN_BITMASK;

		if (!_setOriginalActive) {
			_setOriginalActive = true;

			_originalActive = _active;
		}

		_active = active;
	}

	public boolean getOriginalActive() {
		return _originalActive;
	}

	@JSON
	public long getArticleVersionId() {
		return _articleVersionId;
	}

	public void setArticleVersionId(long articleVersionId) {
		_articleVersionId = articleVersionId;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public VcmsArticleStatus toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (VcmsArticleStatus)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					VcmsArticleStatus.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		VcmsArticleStatusImpl vcmsArticleStatusImpl = new VcmsArticleStatusImpl();

		vcmsArticleStatusImpl.setId(getId());
		vcmsArticleStatusImpl.setStatusId(getStatusId());
		vcmsArticleStatusImpl.setArticleId(getArticleId());
		vcmsArticleStatusImpl.setCategoryId(getCategoryId());
		vcmsArticleStatusImpl.setCreatedDate(getCreatedDate());
		vcmsArticleStatusImpl.setCreatedByUser(getCreatedByUser());
		vcmsArticleStatusImpl.setActive(getActive());
		vcmsArticleStatusImpl.setArticleVersionId(getArticleVersionId());

		vcmsArticleStatusImpl.resetOriginalValues();

		return vcmsArticleStatusImpl;
	}

	public int compareTo(VcmsArticleStatus vcmsArticleStatus) {
		int value = 0;

		value = DateUtil.compareTo(getCreatedDate(),
				vcmsArticleStatus.getCreatedDate());

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		VcmsArticleStatus vcmsArticleStatus = null;

		try {
			vcmsArticleStatus = (VcmsArticleStatus)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = vcmsArticleStatus.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		VcmsArticleStatusModelImpl vcmsArticleStatusModelImpl = this;

		vcmsArticleStatusModelImpl._originalArticleId = vcmsArticleStatusModelImpl._articleId;

		vcmsArticleStatusModelImpl._originalCreatedByUser = vcmsArticleStatusModelImpl._createdByUser;

		vcmsArticleStatusModelImpl._originalActive = vcmsArticleStatusModelImpl._active;

		vcmsArticleStatusModelImpl._setOriginalActive = false;

		vcmsArticleStatusModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<VcmsArticleStatus> toCacheModel() {
		VcmsArticleStatusCacheModel vcmsArticleStatusCacheModel = new VcmsArticleStatusCacheModel();

		vcmsArticleStatusCacheModel.id = getId();

		vcmsArticleStatusCacheModel.statusId = getStatusId();

		vcmsArticleStatusCacheModel.articleId = getArticleId();

		String articleId = vcmsArticleStatusCacheModel.articleId;

		if ((articleId != null) && (articleId.length() == 0)) {
			vcmsArticleStatusCacheModel.articleId = null;
		}

		vcmsArticleStatusCacheModel.categoryId = getCategoryId();

		String categoryId = vcmsArticleStatusCacheModel.categoryId;

		if ((categoryId != null) && (categoryId.length() == 0)) {
			vcmsArticleStatusCacheModel.categoryId = null;
		}

		Date createdDate = getCreatedDate();

		if (createdDate != null) {
			vcmsArticleStatusCacheModel.createdDate = createdDate.getTime();
		}
		else {
			vcmsArticleStatusCacheModel.createdDate = Long.MIN_VALUE;
		}

		vcmsArticleStatusCacheModel.createdByUser = getCreatedByUser();

		String createdByUser = vcmsArticleStatusCacheModel.createdByUser;

		if ((createdByUser != null) && (createdByUser.length() == 0)) {
			vcmsArticleStatusCacheModel.createdByUser = null;
		}

		vcmsArticleStatusCacheModel.active = getActive();

		vcmsArticleStatusCacheModel.articleVersionId = getArticleVersionId();

		return vcmsArticleStatusCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(17);

		sb.append("{id=");
		sb.append(getId());
		sb.append(", statusId=");
		sb.append(getStatusId());
		sb.append(", articleId=");
		sb.append(getArticleId());
		sb.append(", categoryId=");
		sb.append(getCategoryId());
		sb.append(", createdDate=");
		sb.append(getCreatedDate());
		sb.append(", createdByUser=");
		sb.append(getCreatedByUser());
		sb.append(", active=");
		sb.append(getActive());
		sb.append(", articleVersionId=");
		sb.append(getArticleVersionId());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(28);

		sb.append("<model><model-name>");
		sb.append("com.vportal.portlet.vcms.model.VcmsArticleStatus");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>id</column-name><column-value><![CDATA[");
		sb.append(getId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>statusId</column-name><column-value><![CDATA[");
		sb.append(getStatusId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>articleId</column-name><column-value><![CDATA[");
		sb.append(getArticleId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>categoryId</column-name><column-value><![CDATA[");
		sb.append(getCategoryId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createdDate</column-name><column-value><![CDATA[");
		sb.append(getCreatedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createdByUser</column-name><column-value><![CDATA[");
		sb.append(getCreatedByUser());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>active</column-name><column-value><![CDATA[");
		sb.append(getActive());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>articleVersionId</column-name><column-value><![CDATA[");
		sb.append(getArticleVersionId());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = VcmsArticleStatus.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			VcmsArticleStatus.class
		};
	private long _id;
	private long _statusId;
	private String _articleId;
	private String _originalArticleId;
	private String _categoryId;
	private Date _createdDate;
	private String _createdByUser;
	private String _originalCreatedByUser;
	private boolean _active;
	private boolean _originalActive;
	private boolean _setOriginalActive;
	private long _articleVersionId;
	private transient ExpandoBridge _expandoBridge;
	private long _columnBitmask;
	private VcmsArticleStatus _escapedModelProxy;
}